<template>
	<view>
		<u-toast ref="uToast"></u-toast>
		<view class="goshop-list-wrap">
			<view class="goshop-list-item goshop-list-item-bottom" @tap="$Router.push('/pages/common/settings/material')">
				<view class="goshop-list-item-left">
					{{basicinformationText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<view class="goshop-list-item goshop-list-item-bottom" @tap="goAuthPage()">
				<view class="goshop-list-item-left">
					{{certmanagementText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<view class="goshop-list-item goshop-list-item-bottom" @tap="$Router.push('/pages/common/update/new_mobile')" v-if="locale === 'zh-Hans'">
				<view class="goshop-list-item-left">
					{{modifyphoneText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<view class="goshop-list-item goshop-list-item-bottom" @tap="$Router.push('/pages/common/update/new_mail')" v-else>
				<view class="goshop-list-item-left">
					{{modifymailText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<view class="goshop-list-item goshop-list-item-bottom" @tap="goPasswordPage()">
				<view class="goshop-list-item-left">
					{{changepasswordText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<view class="goshop-list-item" @tap="$Router.push('/pages/common/language/language')">
				<view class="goshop-list-item-left">
					{{languageswitchText}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
		</view>
		<view class="goshop-bt-x-10 u-m-t-20">
			<u-button type="error" size="large" @click="logout" :text="signoutText"></u-button>
		</view>
	</view>
</template>

<script>
	import { mapState, mapActions, mapGetters } from 'vuex';
	import {logout} from '@/common/http.api';
	import jwt from '@/utils/jwt.js'
	export default {
		data() {
			return {
				basicinformationText:'',
				certmanagementText:'',
				modifyphoneText:'',
				modifymailText:'',
				changepasswordText:'',
				languageswitchText:'',
				signoutText:'',
				locale:'',
			};
		},
		onShow(){
			this.locale = this.$i18n.locale;
			this.refresh();
		},
		methods:{
			...mapActions(['LogOut']),
			refresh(){
				this.basicinformationText = this.$t('settings.basicinformation.text');
				this.certmanagementText = this.$t('settings.certmanagement.text');
				this.modifyphoneText = this.$t('settings.modifyphone.text');
				this.modifymailText = this.$t('settings.modifymail.text');
				this.changepasswordText = this.$t('settings.changepassword.text');
				this.languageswitchText = this.$t('settings.languageswitch.text');
				this.signoutText = this.$t('common.signout.text');
			},
			goPasswordPage(){
				let locale = this.$i18n.locale;
				if(locale === 'zh-Hans'){
					uni.navigateTo({
						url: "/pages/common/update/password_zh",
					})
				}else{
					uni.navigateTo({
						url: "/pages/common/update/password_en",
					})
				}
			},
			goAuthPage(){
				let locale = this.$i18n.locale;
				if(locale === 'zh-Hans'){
					uni.navigateTo({
						url: "/pages/common/auth/zh_auth",
					})
				}else{
					uni.navigateTo({
						url: "/pages/common/auth/en_auth",
					})
				}
			},
			logout(){
				this.LogOut().then(res => {
					uni.removeStorageSync('vuex_user');
					uni.removeStorageSync('vuex_token');
					jwt.logout();
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/tabbar/home/home'
						});
					}, 500);
				  })
			}
		}
	}
</script>

<style lang="scss">

</style>
